<script type="text/javascript">
    $(document).ready(function() {
        $("#dialog_view").tabs();

        $("#dialog_view").dialog({
            autoOpen: false,
            height: 300,
            width: 500,
            position: ['top', 'middle'],
            resizable: false,
            modal: true
        });

        $(".view-info").click(function() {
            var id_item = $(this).attr("rel");
            // alert(id_item);
            $.get("{$config->site_url('master/barang/view_barang/" + id_item + "')}", function(data) {
                $("#table-list-pengadaan").html(data);
            });
            $("#dialog_view").dialog('open')
        });
    });

    $(function() {
        $("#tabs").tabs();
    });
</script> 
<div class="breadcrum">
    <p>
        <a href="{$config->site_url('master/overview')}">Master</a><span></span><small>Barang</small>
    </p>
    <div class="clear"></div>
</div>
<div class="search-box">
    <h3><a href="#">Search</a></h3>
    <form method="post" action="{$config->site_url('master/barang/proses_cari')}">
        <table width="100%" border="0" class="table-search">
            <tbody>
                <tr>
                    <th width="15%">No Inventaris</th>
                    <td width="15%">
                        <input type="text" style="width: 190px;" maxlength="50" size="30" value="{$search.barang_noinventaris|default:''}" name="barang_noinventaris">
                    </td>
                    <th width="15%">Nama Barang</th>
                    <td width="15%">
                        <input type="text" style="width: 190px;" maxlength="50" size="30" value="{$search.barang_nama|default:''}" name="barang_nama">
                    </td>   
                    <th width="15%">Kondisi Barang</th>
                    <td width="15%">
                        <select style="width: 200px;" name="barang_kondisi" id="barang_kondisi">
                            <option value=""></option>
                            {foreach from=$barang_kondisi item=data}
                            <option value="{$data.data|default:''}" {if {$search.barang_kondisi|default:''} eq $data.data}selected="selected"{/if}>{$data.data}</option>
                            {/foreach}
                        </select>
                    </td>
                </tr>
                <tr>
                    <th width="15%">Barang Status</th>
                    <td width="15%">
                        <select style="width: 200px;" name="barang_status" id="barang_status">
                            <option value=""></option>
                            {foreach from=$barang_status item=data}
                            <option value="{$data.status_cd|default:''}" {if {$search.barang_status|default:''} eq $data.status_cd}selected="selected"{/if}>{$data.status_name}</option>
                            {/foreach}
                        </select>
                    </td>
                    <th width="15%">Group Barang</th>
                    <td width="15%">
                        <select style="width: 200px;" name="gpbarang_cd" style="width:200px">
                            <option value=""></option>
                            {foreach from=$rs_gpbarang item=data}
                            <option value="{$data.gpbarang_cd|default:''}" {if {$search.gpbarang_cd|default:''} eq $data.gpbarang_cd}selected="selected"{/if}>{$data.gpbarang_name}</option>
                            {/foreach}
                        </select>
                    </td>   
                    <th width="15%">Jenis Barang</th>
                    <td width="15%">
                        <select style="width: 200px;" name="jenisbarang_cd" style="width:200px">
                            <option value=""></option>
                            {foreach from=$rs_jenisbarang item=data}
                            <option value="{$data.jenisbarang_cd|default:''}" {if {$search.jenisbarang_cd|default:''} eq $data.jenisbarang_cd}selected="selected"{/if}>{$data.jenisbarang_name}</option>
                            {/foreach}
                        </select>
                    </td>
                </tr>
                <tr>
                    <th width="15%">Kategori Barang</th>
                    <td width="15%">
                        <select style="width: 200px;" name="kategoribarang_cd" id="kategoribarang_cd">
                            <option value=""></option>
                            {foreach from=$rs_kategoribarang item=data}
                            <option value="{$data.kategoribarang_cd|default:''}" {if {$search.kategoribarang_cd|default:''} eq $data.kategoribarang_cd}selected="selected"{/if}>{$data.kategoribarang_name}</option>
                            {/foreach}
                        </select>
                    </td>
                    <th width="15%">Merk Barang</th>
                    <td width="15%">
                        <select  style="width: 200px;" name="merk_cd" id="merk_cd">
                            <option value=""></option>
                            {foreach from=$rs_merk item=data}
                            <option value="{$data.merk_cd|default:''}" {if {$search.merk_cd|default:''} eq $data.merk_cd}selected="selected"{/if}>{$data.merk_name}</option>
                            {/foreach}
                        </select>
                    </td>  
                    <th width="30%">

                    </th>
                </tr>
                <tr>
                    <th colspan="6">
                        <input type="submit" value="Tampilkan" name="save" class="submit">
                        <input type="submit" value="Reset" name="save" class="submit">
                    </th>
                </tr>
            </tbody>
        </table>
    </form>
</div>
<div class="sub-content">
    <div class="navigation"> 
        <div class="pageRow">
            <div class="pageNav">
                <ul>
                    <li class="info"><strong>{$pagination.start|default:'0'} - {$pagination.end|default:'0'}</strong> dari <strong>{$pagination.total|default:'0'}</strong> Data</li>
                    {$pagination.data|default:''}
                </ul>
            </div>
            <div class="clear"></div>
        </div>
        <div class="navigation-button">
            <ul>
                <li><a href="{$config->site_url('master/barang/add')}"><img alt="" src="{$BASEURL}/resource/doc/images/icon/add-icon.png">Tambah Data</a></li>
                <li><a href="{$config->site_url('master/barang/import')}"><img alt="" src="{$BASEURL}/resource/doc/images/icon/printer-icon.png">Import</a></li> 
            </ul>
            <div class="clear"></div>
        </div>
    </div> 
    <!-- notification template -->
    {include file="base/templates/notification.html"}
    <!-- end of notification template--> 
    <table width="100%" class="table-view">
        <tbody>
            <tr>
                <th width="5%">No</th> 
                <th width="15%">No Inventaris</th> 
                <th width="35%">Nama Barang</th> 
                <th width="10%">Harga Beli Barang</th> 
                <th width="10%">Nilai Buku</th>
                <th width="3%"></th>
                <th width="17%"></th>
            </tr>
            {assign var='numb' value={$pagination.start}}
            {foreach from=$rs_id key=no item=result}
            <tr {if ($no % 2) <> 0}class="blink-row"{/if}>
                <td>{$numb++}</td>
                <td>{$result.barang_noinventaris}</td>
                <td>{$result.barang_nama}</td> 
                <td align='right'>{$result.barang_harga_beli|default:'0'|number_format:2:",":"."}</td> 
                <td align='right'>{$result.barang_nilai_buku|default:'0'|number_format:2:",":"."}</td> 
                <td align="center"><a href="#" class="view-info" id="{$result.barang_id}" rel='{$result.barang_id}'><img src="{$BASEURL}/resource/doc/images/icon/view.png"  /></a></td>
                <td align="center">
                    <a href="{$config->site_url({'master/barang/upgrade/'|cat:$result.barang_id})}" class="button-upgrade">Upgrade</a>
                    <a href="{$config->site_url({'master/barang/edit/'|cat:$result.barang_id})}" class="button-edit">Edit</a>
                    <a href="{$config->site_url({'master/barang/delete/'|cat:$result.barang_id})}" class="button-hapus">Hapus</a>
                </td>
            </tr>
            {foreachelse}
            <tr>
                <td colspan="7">Data masih kosong</td>
            </tr>
            {/foreach}
        </tbody>
    </table> 
</div>

<div id="dialog_view" display="none" title="Detail Data"> 
    <table width="100%" class="table-view" id="table-list-pengadaan">

    </table>
</div> 
